'use strict';

/**
 * @name 项目经理关闭进程
 * @author ZYF
 */

angular.module('metalabOperationApp').controller('CloseProcessModelCtrl', ['$scope', '$stateParams', '$state', 'MetaResources', 'MetaRemind', '$uibModalInstance', function($scope, $stateParams, $state, MetaResources, MetaRemind, $uibModalInstance) {
    $scope.cause_for_reason = "";
    $scope.sure = function() {
        if ($scope.cause_for_reason !== "") {
            MetaResources.process.save({
                    'id': $stateParams.id
                }, {
                    'causeForCancel': $scope.cause_for_reason
                },
                function() {
                    MetaRemind.success("恭喜", "进程已经终止");
                    $uibModalInstance.dismiss('cancel');
                    $state.reload();
                },
                function(error) {
                    MetaRemind.serverError(error);
                    $uibModalInstance.dismiss('cancel');
                });
        } else {
            MetaRemind.errorInfo("失败", "请填写理由");
        }
    };
    $scope.cancel = function() {
        $uibModalInstance.dismiss('cancel');
    };
}]);
